//
// Created by liutp on 2022/6/18.
//

#ifndef FFMPEG_WASM_TYPE_H
#define FFMPEG_WASM_TYPE_H


#ifdef __cplusplus
extern "C"
{
#endif

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>

#ifdef __cplusplus
}
#endif

typedef unsigned char u8;
typedef signed char i8;
typedef unsigned short u16;
typedef signed short i16;
typedef unsigned int u32;
typedef signed int i32;
typedef unsigned long long u64;

#pragma pack(1)

typedef struct {
    u8 *data;
    u8 *end;
    u8 *pos;
    u32 size;
} Buffer;

typedef struct Stream {
    u32 displayNumber;
    u8 *yuv_data;
    u32 width;
    u32 height;
    u32 format;
    u32 size_y;
    u32 size_u;
    u32 size_v;
    u8 *data_y;
    u8 *data_u;
    u8 *data_v;
    i8 state;

    //=================
    u32 length;
    u8 *buffer;
    u8 *pos;
    u8 *end;

    enum AVCodecID codecID;
    // AVCodec *codec;
    AVCodecContext *codec_ctx;
    AVFormatContext *format_ctx;
    AVFrame *pFrame;
    AVPacket *pPacket;

    unsigned char *mallocBuffer;
} Stream;

#pragma pack()

#endif //FFMPEG_WASM_TYPE_H
